<template>
    <div class="app-container">
        <el-form :model="queryParams" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="员工来源" prop="sysUserFrom" style="margin-right: 130px;">
                <el-select v-model.trim="queryParams.sysUserFrom" placeholder="请输入员工来源" clearable style="width: 150px">
                    <el-option v-for="dict in sysUserFrom" :key="dict.value" :label="dict.label" :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item label="员工ID" prop="userid" style="margin-right: 130px;">
                <el-input v-model.trim="queryParams.userid" onkeyup="value=value.replace(/[^0-9.]/g,'')"
                    placeholder="请输入员工id" clearable style="width: 150px;" @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="姓名" prop="nickName" style="margin-right: 130px;">
                <el-input v-model.trim="queryParams.nickName" placeholder="请输入姓名" clearable style="width: 150px;"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="用户身份" prop="roleid" style="margin-right: 130px;">
                <el-select v-model.trim="queryParams.roleid" placeholder="请输入员工来源" clearable style="width: 150px">
                    <el-option v-for="dict in remark" :key="dict.key" :label="dict.rolename" :value="dict.roleid" />
                </el-select>
            </el-form-item>
            <el-form-item label="薪资结构" prop="salary1">
                <el-select multiple v-model.trim="salary1" placeholder="请输入薪资结构" clearable style="width: 150px">
                    <el-option v-for="dict in salary" :key="dict.value" :label="dict.label" :value="dict.label" />
                </el-select>
            </el-form-item>
            <el-form-item label="联系方式" prop="phonenumber" style="margin-right: 130px;">
                <el-input v-model.trim="queryParams.phonenumber" onkeyup="value=value.replace(/[^0-9.]/g,'')"
                    placeholder="请输入联系方式" clearable style="width: 150px" @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="状态" prop="status" style="margin-right: 130px;">
                <el-select v-model.trim="queryParams.status" placeholder="用户状态" clearable style="width: 150px">
                    <el-option v-for="dict in status" :key="dict.value" :label="dict.label" :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item label="入职时间">
                <!-- value-format="timestamp" -->
                <el-date-picker v-model.trim="queryParams.startTime" type="date" value-format="timestamp"
                    :picker-options="startDatePicker" placeholder="开始时间" style="width: 150px">
                </el-date-picker>
                <el-date-picker v-model.trim="endTimes" type="date" value-format="timestamp" :picker-options="endDatePicker"
                    placeholder="结束时间" style="width: 150px">
                </el-date-picker>
            </el-form-item>
            <el-form-item style="width: 100%;margin-left: 100px;">
                <el-button type="primary" icon="el-icon-search" size="mini" v-hasPermi="['puser:userlist:query']"
                    @click="handleQuery">搜索
                </el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <!--  v-hasPermi="['system:user:add']" -->
                <el-button type="primary" plain icon="el-icon-plus" size="mini" v-hasPermi="['puser:userlist:add']"
                    @click="handleAdd">新增</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                    v-hasPermi="['puser:userlist:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="ID/账号" align="center">
                <template slot-scope="scope">
                    <div>ID：{{ scope.row.userid }}</div>
                    <div>账号：{{ scope.row.userName }}</div>
                </template>
            </el-table-column>
            <!-- <el-table-column label="员工账号" align="center" prop="userName" /> -->
            <el-table-column label="姓名/手机号" align="center">
                <template slot-scope="scope">
                    <div>姓名：{{ scope.row.nickName }}</div>
                    <div>手机号：{{ scope.row.phonenumber }}</div>
                </template>
            </el-table-column>
            <el-table-column label="员工身份/来源" align="center">
                <template slot-scope="scope">
                    <div>身份：{{ scope.row.remark }}</div>
                    <div>来源：{{ scope.row.sysUserFrom == 1 ? '平台招聘' : '平台员工推荐' }}</div>
                </template>
            </el-table-column>
            <!-- <el-table-column label="用户身份" align="center" prop="remark" />
            <el-table-column label="员工来源" align="center" prop="sysUserFrom" v-if="this.quanxian == false">
                <template slot-scope="scope">
                    <span v-if="scope.row.sysUserFrom == 1">平台招聘</span>
                    <span v-if="scope.row.sysUserFrom == 2">平台员工推荐</span>
                </template>
            </el-table-column> -->
            <el-table-column label="入职时间" align="center" prop="createTime">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.createTime, '{YY}-{MM}-{DD}') }}</span>
                </template>
            </el-table-column>
            <!-- <el-table-column label="手机号码" align="center" prop="phonenumber" /> -->
            <el-table-column label="用户性别" align="center" prop="sex" v-if="this.quanxian == false">
                <template slot-scope="scope">
                    <span v-if="scope.row.sex == '1'">女</span>
                    <span v-if="scope.row.sex == '0'">男</span>
                    <span v-if="scope.row.sex == '2'">未知</span>
                </template>
            </el-table-column>
            <el-table-column label="用户头像" align="center">
                <template slot-scope="scope" width="80px">
                    <el-image :src="scope.row.avatar" alt="" weight="10"></el-image>
                </template>
            </el-table-column>
            <el-table-column label="帐号状态" align="center" prop="status" type="text">
                <template slot-scope="scope">
                    <span v-if="scope.row.status == '1'">禁用</span>
                    <span v-if="scope.row.status == '0'">正常</span>
                </template>
            </el-table-column>
            <el-table-column label="薪资结构" align="center" prop="salaryStructure" v-if="this.quanxian == false" />
            <el-table-column label="账户余额" align="center" prop="puHaveMoney" v-if="this.quanxian == false" />
            <el-table-column label="冻结金额" align="center" prop="puFieezeMoney" v-if="this.quanxian == false" />
            <el-table-column label="无效率" align="center" v-if="this.quanxian == false">
                <template slot-scope="scope">
                    <span>{{scope.row.okRate}}%</span>
                </template>
            </el-table-column>
            <el-table-column label="成交率" align="center" v-if="this.quanxian == false">
                <template slot-scope="scope">
                    <span>{{scope.row.noRate}}%</span>
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <!-- v-hasPermi="['system:user:edit']" -->
                    <el-button size="mini" type="text" icon="el-icon-edit" v-hasPermi="['puser:userlist:edit']"
                        @click="handleUpdate(scope.row)">修改
                    </el-button>
                    <el-button size="mini" type="text" icon="el-icon-view" v-hasPermi="['puser:userlist:look']"
                        @click="handlecheck(scope.row)">查看
                    </el-button>
                    <el-button @click="tuiguang(scope.row)" icon="el-icon-circle-check" size="mini" type="text"
                        v-hasPermi="['puser:userlist:tuiguang']">推广</el-button>
                    <el-dropdown v-hasPermi="['puser:userlist:more']" size="mini"
                        @command="(command) => handleCommand(command, scope.row)">
                        <span class="el-dropdown-link">
                            <i class="el-icon-d-arrow-right el-icon--right"></i>更多
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <!-- v-hasPermi="['system:user:edit']" -->
                            <el-dropdown-item command="handleFollowKZ" v-hasPermi="['puser:userlist:fllowkz']"
                                icon="el-icon-circle-check">跟进客资
                            </el-dropdown-item>
                            <el-dropdown-item command="yinghangka" v-hasPermi="['puser:userlist:yinhangka']"
                                icon="el-icon-circle-check">银行卡
                            </el-dropdown-item>
                            <el-dropdown-item command="details" v-hasPermi="['puser:userlist:jiaoyimingxi']"
                                icon="el-icon-circle-check">交易明细
                            </el-dropdown-item>
                            <el-dropdown-item command="frozenjine" v-hasPermi="['puser:userlist:frozenjine']"
                                icon="el-icon-circle-check">冻结金额
                            </el-dropdown-item>
                            <el-dropdown-item command="frozen" v-hasPermi="['puser:userlist:frozen']"
                                icon="el-icon-circle-check">查看冻结金额
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList"></pagination>
        <!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-change="currentPage" :page-sizes="pageSizes"
          layout="total,sizes,prev,pager,next,jumper" :total="total"></el-pagination> -->
        <!-- 添加员工对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @close="close">
            <p v-if="form.sysUserFrom == '2'" style="margin:10px 0 ;font-size: 16px ;color: #606266; font-weight: 700;">
                推荐人信息
            </p>
            <el-form ref="tuijianform" :model="tuijianform" v-if="form.sysUserFrom == '2'" label-width="90px"
                style="background-color:#f9f9f9;">
                <el-form-item label="员工来源:" style="width: 25%;margin-bottom: 5px;">{{ tuijianform.remark }}</el-form-item>
                <el-form-item label="员工姓名:" style="width: 25%;margin-bottom: 5px;">{{ tuijianform.nickName }}</el-form-item>
                <el-form-item label="性别:" style="width: 25%;margin-bottom: 5px;">{{ tuijianform.sex }}</el-form-item>
                <el-form-item label="联系方式:" style="width: 25%;margin-bottom: 5px;">{{ tuijianform.phonenumber
                }}</el-form-item>
                <el-form-item label="入职时间:" style="width: 50%;margin-bottom: 5px;">{{ parseTime(tuijianform.createTime,
                    '{YY}-{MM}-{DD}')
                }}</el-form-item>
                <el-form-item label="住址:" style="width: 50%;margin-bottom: 5px;">{{ tuijianform.sAddress }}</el-form-item>
                <el-form-item label="薪资结构:" style="margin-bottom: 5px;"><span
                        style="font-weight:700;font-size:'16px'">基本工资:</span>{{ tuijianform.uMoney }};
                    <span style="font-weight:700;font-size:'16px'">一级员工薪资:</span>客资费({{ tuijianform.kzsuccessmoney
                    }}元)+提成({{ tuijianform.tichengmoney }}%)+返利({{ tuijianform.fanlimoney }}元);
                    <span style="font-weight:700;font-size:'16px'">二级推荐:</span>客资费({{ tuijianform.neituikzmoney }}元)+提成({{
                        tuijianform.neituiticheng }}%);
                    <span style="font-weight:700;font-size:'16px'">三级推荐:</span>客资费({{ tuijianform.cituikzmoney }}元)+提成({{
                        tuijianform.cituiticheng }}%);
                </el-form-item>
            </el-form>
            <p style="margin:10px 0 ;font-size: 16px ;color: #606266; font-weight: 700;">员工信息</p>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-form-item label="员工头像" prop="avatar" style="width:400px">
                    <el-upload class="avatar-uploader" :action="url" accept=".jpg, .png" :headers="headers"
                        :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload"
                        :on-progress="progress" name="fileName">
                        <img v-if="form.avatar" :src="form.avatar" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                    <el-progress v-if="isShowJinDuTiao" type="circle" :percentage="percentage" :width="78" class="jdt" />
                </el-form-item>
                <!-- v-if="this.quanxian == true" -->
                <el-form-item label="员工来源" prop="sysUserFrom">
                    <el-select v-model="form.sysUserFrom" placeholder="请输入员工来源" clearable style="width: 204px">
                        <!-- <el-option v-for="dict in sysUserFrom" :key="dict.value" :label="dict.label"
                          :value="dict.value" /> -->
                        <el-option label="平台招聘" value="1"></el-option>
                        <el-option label="平台员工推荐" value="2"></el-option>
                    </el-select>
                    <el-form-item label="推荐人账号" prop="tuijianName" v-if="form.sysUserFrom == '2'"
                        style="width: 250px;margin-left: -100px;margin-top: 10px;">
                        <el-select placeholder="请输入推荐人账号" clearable filterable v-model="form.upUid" style="width:204px"
                            @change="tuijianrenchange($event)">
                            <el-option v-for="item in tuijianren" :key="item.userid" :label="item.userName"
                                :value="item.userid">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form-item>
                <!-- this.quanxian == true -->
                <el-form-item label="员工姓名" prop="nickName" style="width:400px">
                    <el-input v-model.trim="form.nickName" placeholder="请输入员工姓名" style="width:204px" />
                </el-form-item>
                <el-form-item label="员工账号" prop="userName">
                    <el-input v-model.trim="form.userName" placeholder="请输入员工账号" />
                </el-form-item>
                <!-- v-if="this.quanxian == true" -->
                <el-form-item label="性别" prop="sex" style="width:400px">
                    <template>
                        <el-radio-group v-model="form.sex">
                            <el-radio label="0">男</el-radio>
                            <el-radio label="1">女</el-radio>
                        </el-radio-group>
                    </template>
                </el-form-item>
                <el-form-item label="联系方式" prop="phonenumber">
                    <el-input maxlength="11" v-model.trim="form.phonenumber" placeholder="请输入手机号码" />
                </el-form-item>
                <el-form-item label="密码" prop="password" style="width:400px">
                    <el-input v-model.trim="form.password" placeholder="请输入密码" style="width:204px" :type="passwordType"
                        auto-complete="new-password" />
                    <span class="show-pwd" @click="showPwd" id="eye">
                        <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
                    </span>
                </el-form-item>
                <el-form-item label="城市" prop="sAddress">
                    <el-input v-model.trim="form.sAddress" placeholder="请输入住址" />
                </el-form-item>
                <!-- v-if="this.quanxian == true" -->
                <el-form-item label="基本工资" prop="uMoney" style="width:400px">
                    <el-input v-model.trim="form.uMoney" placeholder="请输入基本工资" style="width:204px" />
                </el-form-item>
                <el-form-item label="用户身份" prop="remark">
                    <!-- @change="changes" -->
                    <el-select v-model="form.remark" placeholder="请输入用户身份" clearable style="width: 204px"
                        v-if="this.roles == false">
                        <el-option v-for="dict in remark" :key="dict.key" id="remark" :label="dict.rolename"
                            :value="dict.roleid" />
                    </el-select>
                    <el-select v-model="form.remark" placeholder="请输入用户身份" clearable style="width: 204px"
                        v-if="this.roles == true">
                        <el-option v-for="dict in remarks" :key="dict.key" id="remark" :label="dict.rolename"
                            :value="dict.roleid" />
                    </el-select>
                </el-form-item>
                <el-form-item label="状态" style="width:400px">
                    <el-radio-group v-model="form.status">
                        <el-radio v-for="dict in status" :key="dict.value" :label="dict.value">
                            {{ dict.label }}</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="备注" prop="beizhu">
                    <el-input v-model.trim="form.beizhu" type="textarea" placeholder="请输入备注信息"
                        style="width:204px"></el-input>
                </el-form-item>
                <el-form-item label="一级员工薪资" label-width="110px" prop="salaryStructure" style="width: 400px;">
                    <el-checkbox-group v-model="form.salaryStructure" @change="dianji">
                        <el-checkbox label="客资费" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxOne" type="text" v-model.trim="form.kzsuccessmoney"
                            placeholder="请输入客资费(仅为数字)" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 210px;">
                        </el-input>
                        <el-checkbox label="提成" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxTwo" v-model.trim="form.tichengmoney" placeholder="请输入提成比率(仅为数字)"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}"
                            style="width: 210px;">
                            <span slot='suffix'>%</span>
                        </el-input>
                        <el-checkbox label="返利" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxThree" type="text" v-model.trim="form.fanlimoney" placeholder="请输入返利(仅为数字)"
                            oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 210px;">
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="二级推荐" prop="salaryStructure" style="width: 320px;" v-if="form.sysUserFrom == '2'">
                    <el-checkbox-group v-model="form.salaryStructure" @change="dianji1">
                        <el-checkbox label="客资费(上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxFore" type="text" v-model.trim="form.neituikzmoney"
                            placeholder="请输入客资费(仅为数字)" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 210px;">
                        </el-input>
                        <el-checkbox label="提成(上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxFive" v-model.trim="form.neituiticheng" placeholder="请输入提成比率(仅为数字)"
                            style="width: 210px;" onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}">
                            <span slot='suffix'>%</span>
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="三级推荐" prop="salaryStructure" style="width: 320px;" v-if="form.sysUserFrom == '2'">
                    <el-checkbox-group v-model="form.salaryStructure" @change="dianji2">
                        <el-checkbox label="客资费(上上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxsix" type="text" v-model.trim="form.cituikzmoney" placeholder="请输入客资费(仅为数字)"
                            oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 210px;">
                        </el-input>
                        <el-checkbox label="提成(上上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxseven" v-model.trim="form.cituiticheng" placeholder="请输入提成比率(仅为数字)"
                            prop="cituiticheng" style="width: 210px;" :min="0" :max="100"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}">
                            <span slot='suffix'>%</span>
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" :disabled="lock" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
        <!-- 修改员工对话框 -->
        <el-dialog :title="title" :visible.sync="open2" width="800px" append-to-body @close="handleClose">
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-form-item label="员工头像" prop="avatar" style="width:400px">
                    <!--   v-loading.lock="loading1" element-loading-spinner="el-icon-loading"
                        element-loading-background="rgba(0,0,0,0.1)"  -->
                    <el-upload class="avatar-uploader" :action="url" accept=".jpg, .png" :headers="headers"
                        :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload"
                        :on-progress="progress" name="fileName">
                        <img v-if="form.avatar" :src="form.avatar" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                        <el-progress v-if="isShowJinDuTiao" type="circle" :percentage="percentage" :width="78"
                            class="jdt" />
                    </el-upload>
                </el-form-item>
                <el-form-item label="员工来源" prop="sysUserFrom" v-if="this.quanxian == false">
                    <el-select v-model="form.sysUserFrom" placeholder="请输入员工来源" clearable style="width: 204px"
                        :disabled="true">
                        <el-option v-for="dict in sysUserFrom" :key="dict.value" :label="dict.label" :value="dict.value" />
                    </el-select>
                    <el-form-item label="推荐人账号" prop="tuijianName" v-if="form.sysUserFrom == '2' && this.quanxian == false"
                        style="width: 250px;margin-left: -100px;margin-top: 10px;">
                        <el-select placeholder="请输入推荐人账号" filterable v-model="form.upUid" :disabled="true"
                            style="width:204px">
                            <el-option v-for="item in tuijianren" :key="item.userid" :label="item.userName"
                                :value="item.userid">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="员工姓名" prop="nickName" style="width: 400px;">
                    <el-input v-model="form.nickName" placeholder="请输入员工姓名" style="width:204px" />
                </el-form-item>
                <el-form-item label="员工账号" prop="userName">
                    <el-input v-model="form.userName" placeholder="请输入员工账号" :disabled="true" style="width:204px" />
                </el-form-item>
                <el-form-item label="性别" prop="sex" style="width: 400px;" v-if="this.quanxian == false">
                    <el-radio-group v-model="form.sex">
                        <el-radio label="0">男</el-radio>
                        <el-radio label="1">女</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="联系方式" prop="phonenumber">
                    <el-input maxlength="11" v-model="form.phonenumber" placeholder="请输入手机号码" style="width:204px" />
                </el-form-item>
                <el-form-item label="密码" prop="" style="width: 400px;">
                    <el-input v-model="form.password" placeholder="请输入密码" style="width:204px" :type="passwordType"
                        auto-complete="new-password" />
                    <span class="show-pwd" @click="showPwd" id="eye">
                        <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
                    </span>
                </el-form-item>
                <el-form-item label="住址" prop="sAddress">
                    <el-input v-model="form.sAddress" placeholder="请输入住址" />
                </el-form-item>
                <el-form-item label="基本工资" prop="uMoney" style="width: 400px;" v-if="this.quanxian == false">
                    <el-input v-model="form.uMoney" placeholder="请输入基本工资" style="width:204px" />
                </el-form-item>
                <el-form-item label="用户身份" prop="remark">
                    <!--  @change=changes -->
                    <el-select v-model="form.remark" placeholder="请输入用户身份" clearable style="width: 204px"
                        v-if="this.roles == false">
                        <el-option v-for="dict in remark" :key="dict.key" id="remark" :label="dict.rolename"
                            :value="dict.roleid" />
                    </el-select>
                    <el-select v-model="form.remark" placeholder="请输入用户身份" clearable style="width: 204px"
                        v-if="this.roles == true">
                        <el-option v-for="dict in remarks" :key="dict.key" id="remark" :label="dict.rolename"
                            :value="dict.roleid" />
                    </el-select>
                </el-form-item>
                <el-form-item label="状态" style="width: 400px;">
                    <el-radio-group v-model="form.status">
                        <el-radio v-for="dict in status" :key="dict.value" :label="dict.value">
                            {{ dict.label }}</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="备注" prop="beizhu">
                    <el-input v-model="form.beizhu" type="textarea" placeholder="请输入备注信息"></el-input>
                </el-form-item>
                <el-form-item label="一级员工薪资" label-width="110px" prop="salaryStructure" v-if="this.quanxian == false"
                    style="width:400px">
                    <el-checkbox-group v-model="form.salaryStructure" @change="dianji3">
                        <el-checkbox label="客资费" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxOne" v-model="form.kzsuccessmoney" placeholder="请输入客资费"
                            style="width: 204px;" />
                        <el-checkbox label="提成" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxTwo" v-model="form.tichengmoney" placeholder="请输入提成比率"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}"
                            style="width: 204px;">
                            <span slot='suffix'>%</span>
                        </el-input>
                        <el-checkbox label="返利" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxThree" v-model="form.fanlimoney" placeholder="请输入返利金额"
                            oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 204px;" />
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="二级推荐" prop="salaryStructure" v-if="form.sysUserFrom == '2'">
                    <el-checkbox-group v-model="form.salaryStructure" @change="dianji4">
                        <el-checkbox label="客资费(上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxFore" type="text" prop="neituikzmoney" v-model.trim="form.neituikzmoney"
                            placeholder="请输入客资费(仅为数字)" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 204px;">
                        </el-input>
                        <el-checkbox label="提成(上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxFive" v-model.trim="form.neituiticheng" placeholder="请输入提成比率(仅为数字)"
                            prop="neituiticheng" style="width: 204px;" :min="0" :max="100"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}">
                            <span slot='suffix'>%</span>
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="三级推荐" prop="salaryStructure" v-if="form.sysUserFrom == '2'">
                    <el-checkbox-group v-model="form.salaryStructure" @change="dianji5">
                        <el-checkbox label="客资费(上上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxsix" type="text" prop="cituikzmoney" v-model.trim="form.cituikzmoney"
                            placeholder="请输入客资费(仅为数字)" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 204px;">
                        </el-input>
                        <el-checkbox label="提成(上上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxseven" v-model.trim="form.cituiticheng" placeholder="请输入提成比率(仅为数字)"
                            prop="cituiticheng" style="width: 204px;" :min="0" :max="100"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}">
                            <span slot='suffix'>%</span>
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" :disabled="lock1" @click="xiugai">确 定</el-button>
                <el-button @click="quxiao">取 消</el-button>
            </div>
        </el-dialog>
        <!-- 查看员工详细信息 -->
        <el-dialog :title="title1" :visible.sync="open1" width="800px" append-to-body>
            <el-form ref="checkform" :model="checkform" label-width="150px" :disabled="edit">
                <el-form-item label="用户头像" align="center" style="width:350px">
                    <el-upload class="avatar-uploader" :action="url" accept=".jpg, .png" :headers="headers"
                        :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload"
                        :on-progress="progress" name="fileName">
                        <img v-if="checkform.avatar" :src="checkform.avatar" class="avatar" style="margin-left:-100px">
                    </el-upload>
                </el-form-item>
                <el-form-item label="员工来源" prop="sysUserFrom" v-if="this.quanxian == false" style="width:350px">
                    <el-select v-model="checkform.sysUserFrom" placeholder="请输入员工来源" clearable style="width: 204px">
                        <el-option v-for="dict in sysUserFrom" :key="dict.value" :label="dict.label" :value="dict.value" />
                    </el-select>
                    <el-form-item label="推荐人账号" prop="tuijianName"
                        style="width: 350px;margin-left: -150px;margin-top: 10px;"
                        v-if="this.quanxian == false && this.checkform.sysUserFrom == 2">
                        <el-select placeholder="请输入推荐人账号" filterable v-model="checkform.upUid" style="width:204px">
                            <el-option v-for="item in tuijianren" :key="item.userid" :label="item.userName"
                                :value="item.userid">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="员工姓名" prop="nickName">
                    <el-input v-model="checkform.nickName" placeholder="请输入员工姓名" />
                </el-form-item>
                <el-form-item label="员工账号" prop="userName">
                    <el-input v-model="checkform.userName" placeholder="请输入员工账号" />
                </el-form-item>
                <el-form-item label="性别" prop="sex" v-if="this.quanxian == false" style="width:350px">
                    <el-radio-group v-model="checkform.sex">
                        <el-radio label="0">男</el-radio>
                        <el-radio label="1">女</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="联系方式" prop="phonenumber">
                    <el-input v-model="checkform.phonenumber" placeholder="请输入手机号码" />
                </el-form-item>
                <el-form-item label="住址" prop="sAddress">
                    <el-input v-model="checkform.sAddress" placeholder="请输入住址" />
                </el-form-item>
                <el-form-item label="入职时间" prop="creatTime">
                    <el-date-picker clearable v-model="checkform.createTime" type="date" placeholder="入职时间时间"
                        style="width:204px">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="基本工资" prop="uMoney">
                    <el-input v-model="checkform.uMoney" placeholder="请输入基本工资" />
                </el-form-item>
                <el-form-item label="用户身份" prop="remark">
                    <el-input v-model="checkform.remark" placeholder="请输入用户身份(平台员工，管理员)" />
                </el-form-item>
                <el-form-item label="状态" style="width:350px">
                    <el-radio-group v-model="checkform.status">
                        <el-radio v-for="dict in status" :key="dict.value" :label="dict.value">
                            {{ dict.label }}</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="备注" prop="beizhu">
                    <el-input v-model="checkform.beizhu" type="textarea" />
                </el-form-item>
                <el-form-item label="薪资结构" prop="salaryStructure" v-if="this.quanxian == false">
                    <el-checkbox-group v-model="checkform.salaryStructure" @change="dianji">
                        <el-checkbox label="客资费" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxOne" v-model="checkform.kzsuccessmoney" placeholder="请输入客资费"
                            style="width:204px;" />
                        <el-checkbox label="提成" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxTwo" v-model="checkform.tichengmoney" placeholder="请输入提成比率"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}"
                            style="width: 204px;">
                            <span slot='suffix'>%</span>
                        </el-input>
                        <el-checkbox label="返利" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxThree" v-model="checkform.fanlimoney" placeholder="请输入返利金额"
                            oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 204px;" />
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="内推提成" prop="salaryStructure" style="width: 320px;" v-if="checkform.sysUserFrom == '2'">
                    <el-checkbox-group v-model="checkform.salaryStructure" @change="dianji1">
                        <el-checkbox label="客资费(上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxFore" type="text" prop="neituikzmoney"
                            v-model.trim="checkform.neituikzmoney" placeholder="请输入客资费(仅为数字)"
                            oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 204px;">
                        </el-input>
                        <el-checkbox label="提成(上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxFive" v-model.trim="checkform.neituiticheng" placeholder="请输入提成比率(仅为数字)"
                            prop="neituiticheng" style="width: 204px;" :min="0" :max="100"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}">
                            <span slot='suffix'>%</span>
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>
                <el-form-item label="次推提成" prop="salaryStructure" style="width: 320px;" v-if="checkform.sysUserFrom == '2'">
                    <el-checkbox-group v-model="checkform.salaryStructure" @change="dianji2">
                        <el-checkbox label="客资费(上上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxsix" type="text" prop="cituikzmoney" v-model.trim="checkform.cituikzmoney"
                            placeholder="请输入客资费(仅为数字)" oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 204px;">
                        </el-input>
                        <el-checkbox label="提成(上上级)" style="display: block;"></el-checkbox>
                        <el-input v-if="checkboxseven" v-model.trim="checkform.cituiticheng" placeholder="请输入提成比率(仅为数字)"
                            prop="cituiticheng" style="width: 204px;" :min="0" :max="100"
                            onkeyup="value=value.replace(/[^0-9.]/g,'')"
                            oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=0} if(value>100){value=100}">
                            <span slot='suffix'>%</span>
                        </el-input>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>
        </el-dialog>
        <!-- 冻结金额操作 -->
        <el-dialog :title="title2" :visible.sync="open3" width="500px" append-to-body>
            <el-form :model="form1" ref="form1" :rules="rules1" size="small" :inline="true" label-width="150px">
                <el-form-item label="冻结金额" prop="cmmoney">
                    <el-input v-model="form1.cmmoney" placeholder="请输入冻结金额" type="text" clearable style="width: 180px">
                    </el-input>
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                    <el-input v-model="form1.remark" placeholder="备注" type="textarea" clearable style="width: 180px">
                    </el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" :disabled="lock2" @click="sbumit">确 定</el-button>
                <el-button @click="cancel1">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { checkPermi, checkRole } from "@/utils/permission.js";
import { selectAllSysUserPC, getUser, addUser, updateUser, selectAllxL, excelyuangong, adminfindAllRole } from "@/api/puser/userlist.js";
import { djinsertjiedong } from "@/api/puser/account.js"
import { getToken } from '@/utils/auth'
import { options } from "runjs";
import { transformCoordWithViewport } from "zrender/lib/core/dom";
export default {
    name: "Userlist",
    data() {
        return {
            passwordType: 'password',
            lock: false,
            lock1: false,
            lock2: false,
            endTimes: '',
            isShowJinDuTiao: false,
            percentage: 0,
            loading1: false,
            isshow: false,
            quanxian: false,
            url: process.env.VUE_APP_BASE_API + "/upload/fileUpload",
            // pageSizes: [10, 20, 30, 40, 50],
            // currentPage: 1,
            headers: {
                Authorization: "Bearer " + getToken(),
            },
            // 薪资结构
            salary: [{
                value: '0',
                label: '客资费'
            }, {
                value: '1',
                label: '提成'
            }, {
                value: '2',
                label: '提成(上级)'
            }, {
                value: '3',
                label: '返利'
            }, {
                value: '4',
                label: '客资费(上级)'
            }],
            // 用户身份
            remark: [],
            remarks: [{
                roleid: 112,
                rolename: '平台员工'
            }],
            // 推荐人账号
            tuijianren: [],
            //   员工来源
            sysUserFrom: [{
                value: 1,
                label: '平台招聘'
            }, {
                value: 2,
                label: '平台员工推荐'
            }],
            // 员工状态
            status: [{
                value: '0',
                label: '正常'
            }, {
                value: '1',
                label: '停用'
            }],
            // 搜索
            searchdata: {
                sysUserFrom: "",
                nickName: "",
                phonenumber: "",
                status: "",
                startTime: "",
                endTime: "",
                remark: '',
            },
            // 遮罩层
            loading: true,
            edit: true,
            // 显示搜索条件
            showSearch: true,
            sex: 0,
            // 总条数
            total: 0,
            // 表格数据
            userList: [],
            // 弹出层标题
            title: "",
            title1: "",
            title2: "",
            // 是否显示弹出层
            open: false,
            open1: false,
            open2: false,
            open3: false,
            roles: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                sysUserFrom: "",
                nickName: "",
                phonenumber: "",
                status: "",
                startTime: "",
                endTime: "",
                roleid: '',
                userid: '',
                salaryStructure: [],
            },
            salary1: [],
            // 表单参数
            form: {
                nickName: '',
                upUid: '',
                userName: '',
                sex: '0',
                phonenumber: '',
                // password: '',
                sAddress: '',
                creatTime: '',
                uMoney: '',
                remark: '',
                status: '0',
                salaryStructure: [],
                salaryStructure1: [],
                sysUserFrom: '',
                fanlimoney: '',
                kzsuccessmoney: '',
                shoutuimoney: '',
                tichengmoney: '',
                sharemoney: '',
                beizhu: '',
            },
            form1: {
                userId: '',
                cmmoney: '',
                remark: '',
            },
            // 推荐人form
            tuijianform: {
                remark: '',
                userName: '',
                sex: '',
                phonenumber: '',
                sAddress: '',
                createTime: '',
                // 基本工资
                uMoney: '',
                // 一级员工薪资
                //客资费
                kzsuccessmoney: '',
                // 提成
                tichengmoney: '',
                // 返利
                fanlimoney: '',
                // 二级员工推荐
                // 客资费
                neituikzmoney: '',
                // 提成
                neituiticheng: '',
                // 三级推荐
                // 客资费
                cituikzmoney: '',
                // 提成
                cituiticheng: '',

            },
            // 表单校验
            rules: {
                salaryStructure: [{ type: 'array', required: true, message: '薪资结构不能为空', trigger: 'change' }],
                userName: [
                    { required: true, message: "用户账号不能为空", trigger: "blur" },
                    // { pattern: /^[0-9a-zA-Z]{3,}$/, message: '用户账号长度为数字加字母大于3位', trigger: 'blur' }
                    { pattern: /[A-Za-z_0-9]{3,}$/, message: '数字下划线字母大于3位', trigger: 'blur' }
                ],
                nickName: [
                    { required: true, message: "姓名不能为空", trigger: "blur" }
                ],
                sysUserFrom: [
                    { required: true, message: "员工来源不能为空", trigger: "blur" }
                ],
                // upUid: [{ required: true, message: "推荐人id不能为空", trigger: "blur" }],
                sex: [{ required: true, message: "性别不能为空", trigger: "blur" }],
                phonenumber: [{ required: true, message: "联系方式不能为空", trigger: "blur" },
                {
                    pattern: /^1([38][0-9]|4[014-9]|[59][0-35-9]|6[2567]|7[0-8])\d{8}$/,
                    message: "请输入正确的手机号码",
                    trigger: "blur"
                }],
                sAddress: [{ required: true, message: "地址不能为空", trigger: "blur" }],
                password: [
                    // { required: true, message: "密码不能为空", trigger: "blur" },
                    { pattern: /^[0-9a-zA-Z]{6,}$/, message: '密码长度为数字加字母6位以上', trigger: 'blur' }
                ],
                uMoney: [{ required: true, message: "基本工资不能为空", trigger: "blur" }, { pattern: /^[0-9]*$/, message: '基本工资必须为整数', trigger: 'blur' }],
                remark: [{ required: true, message: "用户身份不能为空", trigger: "blur" }],
                neituiticheng: [{ pattern: /^(((\d|[1-9]\d)(\.\d{1,2})?)|100|100.0|100.00)$/, message: '内推提成不能大于100%', trigger: 'blur' }],
            },
            rules1: { cmmoney: [{ required: true, message: "冻结金额不能为空", trigger: "blur" }] },
            // 查看员工信息表单
            checkform: {
                avatar: '',
                userid: '',
                nickName: '',
                nickName: '',
                sex: '',
                sysUserFrom: '',
                status: '',
                remark: '',
                creatTime: '',
                phonenumber: '',
                sAddress: '',
                beizhu: ''
            },
            checkboxOne: false,
            checkboxTwo: false,
            checkboxThree: false,
            checkboxFore: false,
            checkboxFive: false,
            checkboxsix: false,
            checkboxseven: false,
            date: {
                userid: ''
            },
            startDatePicker: this.beginDate(),
            endDatePicker: this.processDate(),
        };
    },
    created() {
        this.getList();
        this.quanxian = checkRole(['shangjia']);
        this.roles = checkRole(['renshikefu']);
        // console.log(this.roles, '111111111');
        // 获取用户身份
        adminfindAllRole().then(response => {
            if (response.code == 200) {
                this.remark = response.data;
            }
        })
    },
    methods: {
        showPwd() {
            if (this.passwordType === 'password') {
                this.passwordType = 'text'
            } else {
                this.passwordType = 'password'
            }
        },
        close() {
            this.tuijianform = {
                remark: '',
                userName: '',
                sex: '',
                phonenumber: '',
                sAddress: '',
                createTime: '',
                // 基本工资
                uMoney: '',
                // 一级员工薪资
                //客资费
                kzsuccessmoney: '',
                // 提成
                tichengmoney: '',
                // 返利
                fanlimoney: '',
                // 二级员工推荐
                // 客资费
                neituikzmoney: '',
                // 提成
                neituiticheng: '',
                // 三级推荐
                // 客资费
                cituikzmoney: '',
                // 提成
                cituiticheng: '',

            }
        },
        tuijianrenchange(event) {
            const userid = event;
            getUser({ userid: userid }).then(res => {
                if (res.data.code == 200) {
                    this.tuijianform.remark = res.data.data.remark;
                    this.tuijianform.nickName = res.data.data.nickName;
                    this.tuijianform.sex = res.data.data.sex;
                    if (this.tuijianform.sex == '0') {
                        this.tuijianform.sex = '男'
                    } else if (this.tuijianform.sex == '1') {
                        this.tuijianform.sex = '女'
                    }
                    this.tuijianform.phonenumber = res.data.data.phonenumber;
                    this.tuijianform.sAddress = res.data.data.sAddress;
                    this.tuijianform.createTime = res.data.data.createTime;
                    this.tuijianform.uMoney = res.data.data.uMoney;
                    this.tuijianform.kzsuccessmoney = res.data.data.kzsuccessmoney;
                    this.tuijianform.tichengmoney = res.data.data.tichengmoney;
                    this.tuijianform.fanlimoney = res.data.data.fanlimoney;
                    this.tuijianform.neituikzmoney = res.data.data.neituikzmoney;
                    this.tuijianform.neituiticheng = res.data.data.neituiticheng;
                    this.tuijianform.cituikzmoney = res.data.data.cituikzmoney;
                    this.tuijianform.cituiticheng = res.data.data.cituiticheng;
                }
            })
        },
        handleClose() {
            this.reset();
            this.checkboxOne = false;
            this.checkboxTwo = false;
            this.checkboxThree = false;
            this.checkboxFore = false;
            this.checkboxFive = false;
            this.checkboxsix = false;
            this.checkboxseven = false;
            this.getList();
        },
        /** 查询列表 */
        async getList() {
            this.loading = true;
            let that = this;
            let res = await selectAllSysUserPC(this.queryParams);
            if (res.code == 200) {
                this.userList = res.rows
                this.total = res.total;
                this.loading = false;
                for (let i = 0; i < that.userList.length; i++) {
                    that.avatar = that.userList[i].avatar;
                }
            }
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        quxiao() {
            this.open2 = false;
        },
        // 表单重置
        reset() {
            this.form = {
                userId: null,
                deptId: null,
                userName: null,
                upUid: null,
                nickName: null,
                userType: null,
                email: null,
                phonenumber: null,
                sex: '0',
                avatar: null,
                password: null,
                status: "0",
                delFlag: null,
                loginIp: null,
                // loginDate: null,
                createBy: null,
                createTime: null,
                updateBy: null,
                updateTime: null,
                remark: null,
                uMoney: null,
                salaryStructure: [],
                sAddress: null,
                sysUserFrom: null
            };
            this.checkboxOne = false;
            this.checkboxTwo = false;
            this.checkboxThree = false;
            this.checkboxFore = false;
            this.checkboxFive = false;
            this.checkboxsix = false;
            this.checkboxseven = false;
            this.resetForm("form");
        },

        /** 搜索按钮操作 */
        handleQuery() {
            let that = this;
            that.queryParams.salaryStructure = this.salary1.join("+");
            if (this.queryParams.startTime == '' && this.endTimes == "") {
                selectAllSysUserPC(this.queryParams).then(response => {
                    this.userList = response.rows;
                    this.total = response.total
                })
            } else if (this.queryParams.startTime == "" && this.endTimes != '') {
                this.$modal.msgError("请输入开始时间");
            } else if (this.queryParams.startTime != '' && this.endTimes == '') {
                this.$modal.msgError("请输入结束时间");
            } else if (this.queryParams.startTime != '' && this.endTimes != '' && this.queryParams.startTime > this.endTimes) {
                this.$modal.msgError("结束时间必须大于开始时间");
            } else if (this.queryParams.startTime != '' && this.endTimes != '' && this.queryParams.startTime < this.endTimes) {
                this.queryParams.endTime = this.endTimes + 24 * 60 * 60 * 1000 - 1;
                selectAllSysUserPC(this.queryParams).then(response => {
                    this.userList = response.rows;
                    this.total = response.total
                })
            } else if (this.queryParams.startTime == this.queryParams.endTime) {
                this.$modal.msgError("结束时间必须大于开始时间");
            }
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                sysUserFrom: "",
                nickName: "",
                phonenumber: "",
                status: "",
                startTime: "",
                endTime: "",
                salaryStructure: []
            };
            this.salary1 = [];
            this.endTimes = '';
            this.getList();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.userId)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "添加员工信息";
            // 获取推荐人信息
            selectAllxL().then(response => {
                this.tuijianren = response.data.data;
            });
            // 获取用户身份
            adminfindAllRole().then(response => {
                if (response.code == 200) {
                    this.remark = response.data;
                    this.form.remark = 112;
                }
            })
        },
        submitForm() {
            this.$refs["form"].validate(valid => {
                const Form = { ...this.form }
                Form.salaryStructure = Form.salaryStructure.join('+')
                if (valid) {
                    this.lock = true;
                    addUser(Form).then(response => {
                        if (response.data.code == 200) {
                            this.lock = false;
                            this.$modal.msgSuccess(response.data.msg);
                            this.open = false;
                            this.getList();
                        } else {
                            this.lock = false;
                            this.$modal.msgError(response.data.msg);
                        }

                    });
                }
            })
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.open2 = true
            this.title = "修改员工信息"
            this.date.userid = row.userid;
            getUser(this.date).then(response => {
                this.form = response.data.data;
                this.form.remark = response.data.data.roleid;
                response.data.data.salaryStructure = response.data.data.salaryStructure.split('+')
                this.form = response.data.data;
                if (this.form.salaryStructure.indexOf('客资费') != -1) {
                    this.checkboxOne = true;
                } else {
                    this.checkboxOne = false;
                    this.form.kzsuccessmoney = 0;
                };
                if (this.form.salaryStructure.indexOf('提成') != -1) {
                    this.checkboxTwo = true;
                } else {
                    this.checkboxTwo = false;
                    this.form.tichengmoney = 0;
                };
                if (this.form.salaryStructure.indexOf('返利') != -1) {
                    this.checkboxThree = true;
                } else {
                    this.checkboxThree = false;
                    this.form.fanlimoney = 0;
                };
                if (this.form.salaryStructure.indexOf('客资费(上级)') != -1) {
                    this.checkboxFore = true;
                } else {
                    this.checkboxFore = false;
                    this.form.neituikzmoney = 0;
                };
                if (this.form.salaryStructure.indexOf('提成(上级)') != -1) {
                    this.checkboxFive = true;
                } else {
                    this.checkboxFive = false;
                    this.form.neituiticheng = 0;
                };
                if (this.form.salaryStructure.indexOf('客资费(上上级)') != -1) {
                    this.checkboxsix = true;
                } else {
                    this.checkboxsix = false;
                    this.form.cituikzmoney = 0;
                };
                if (this.form.salaryStructure.indexOf('提成(上上级)') != -1) {
                    this.checkboxseven = true;
                } else {
                    this.checkboxseven = false;
                    this.form.cituiticheng = 0;
                };
            });
            selectAllxL().then(response => {
                this.tuijianren = response.data.data;
            });
            // 获取用户身份
            adminfindAllRole().then(response => {
                if (response.code == 200) {
                    this.remark = response.data;
                }
            })
        },
        // 修改
        xiugai() {
            const Form = { ...this.form };
            Form.userName = "";
            Form.salaryStructure = Form.salaryStructure.join('+');
            this.$refs["form"].validate(valid => {
                if (valid) {
                    this.lock1 = true;
                    updateUser(Form).then(response => {
                        if (response.data.code == 200) {
                            this.lock1 = false;
                            this.$modal.msgSuccess(response.data.msg);
                            this.open2 = false;
                            this.getList();
                        } else {
                            this.lock1 = false;
                            this.$modal.msgError(response.data.msg)
                        }
                    });
                }
            })

        },
        // 查看员工详细信息
        handlecheck(row) {
            this.reset();
            const userid = row.userid || this.ids
            getUser({ userid: row.userid }).then(response => {
                this.checkform = response.data.data;
                if (response.data.data.beizhu == '') {
                    this.checkform.beizhu = '暂无'
                }
                if (this.checkform.salaryStructure.indexOf('客资费') != -1) {
                    this.checkboxOne = true;
                } else {
                    this.checkboxOne = false;
                    this.checkform.kzsuccessmoney = '';
                };
                if (this.checkform.salaryStructure.indexOf('提成') != -1) {
                    this.checkboxTwo = true;
                } else {
                    this.checkboxTwo = false;
                    this.checkform.tichengmoney = '';
                };
                if (this.checkform.salaryStructure.indexOf('返利') != -1) {
                    this.checkboxThree = true;
                } else {
                    this.checkboxThree = false;
                    this.checkform.fanlimoney = '';
                };
                if (this.checkform.salaryStructure.indexOf('客资费(上级)') != -1) {
                    this.checkboxFore = true;
                } else {
                    this.checkboxFore = false;
                    this.checkform.neituikzmoney = '';
                };
                if (this.checkform.salaryStructure.indexOf('提成(上级)') != -1) {
                    this.checkboxFive = true;
                } else {
                    this.checkboxFive = false;
                    this.checkform.neituiticheng = '';
                };
                if (this.checkform.salaryStructure.indexOf('客资费(上上级)') != -1) {
                    this.checkboxsix = true;
                } else {
                    this.checkboxsix = false;
                    this.checkform.cituikzmoney = '';
                };
                if (this.checkform.salaryStructure.indexOf('提成(上上级)') != -1) {
                    this.checkboxseven = true;
                } else {
                    this.checkboxseven = false;
                    this.checkform.cituiticheng = '';
                };
                this.open1 = true;
                this.title1 = "查看员工信息";
            });
        },
        // 更多操作触发
        handleCommand(command, row) {
            switch (command) {
                case "handleFollowKZ":
                    this.handleFollowKZ(row);
                    break;
                case "yinghangka":
                    this.yinghangka(row);
                    break;
                case "details":
                    this.details(row);
                    break;
                case "frozenjine":
                    this.frozenjine(row);
                    break;
                case "frozen":
                    this.frozen(row);
                    break;
                default:
                    break;
            }
        },
        /** 跟进客资操作 */
        handleFollowKZ: function (row) {
            const userid = row.userid;
            this.$router.push({
                name: "followKZ",
                query: { userid: row.userid }
            });
        },
        // 上传头像
        handleAvatarSuccess(res, file) {
            this.form.avatar = res.data;
            this.loading1 = false;
            this.isShowJinDuTiao = false;
            this.percentage = 0;
        },
        beforeAvatarUpload(file) {
            const isJPG = file.type === 'image/jpeg';
            const isLt2M = file.size / 1024 / 1024 < 2;
            this.loading1 = true;
            this.isShowJinDuTiao = true;
        },
        progress(event, file, fileList) {
            let num = ((event.loaded / event.total) * 100) | 0;
            this.percentage = num;
        },
        dianji(val) {
            if (val.indexOf('客资费') != -1) {
                this.checkboxOne = true;
            } else {
                this.checkboxOne = false;
            }
            if (val.indexOf('提成') != -1) {
                this.checkboxTwo = true;
            } else {
                this.checkboxTwo = false;
            }
            if (val.indexOf('返利') != -1) {
                this.checkboxThree = true;
            } else {
                this.checkboxThree = false;
            }
        },
        dianji1(val) {
            if (val.indexOf('客资费(上级)') != -1) {
                this.checkboxFore = true;
            } else {
                this.checkboxFore = false;
            }
            if (val.indexOf('提成(上级)') != -1) {
                this.checkboxFive = true;
            } else {
                this.checkboxFive = false;
            }
        },
        dianji2(val) {
            if (val.indexOf('客资费(上上级)') != -1) {
                this.checkboxsix = true;
            } else {
                this.checkboxsix = false;
            }
            if (val.indexOf('提成(上上级)') != -1) {
                this.checkboxseven = true;
            } else {
                this.checkboxseven = false;
            }
        },
        dianji3(val) {
            if (val.indexOf('客资费') != -1) {
                this.checkboxOne = true;
            } else {
                this.checkboxOne = false;
                if (this.checkboxOne == false) {
                    this.form.kzsuccessmoney = 0;
                }
            }
            if (val.indexOf('提成') != -1) {
                this.checkboxTwo = true;
            } else {
                this.checkboxTwo = false;
                if (this.checkboxTwo == false) {
                    this.form.tichengmoney = 0;
                }
            }
            if (val.indexOf('返利') != -1) {
                this.checkboxThree = true;
            } else {
                this.checkboxThree = false;
                if (checkboxThree == false) {
                    this.form.fanlimoney = 0;
                }
            }
        },
        dianji4(val) {
            if (val.indexOf('客资费(上级)') != -1) {
                this.checkboxFore = true;
            } else {
                this.checkboxFore = false;
                if (this.checkboxFore == false) {
                    this.form.neituikzmoney = 0;
                }
            }
            if (val.indexOf('提成(上级)') != -1) {
                this.checkboxFive = true;
            } else {
                this.checkboxFive = false;
                if (this.checkboxFive == false) {
                    this.form.neituiticheng = 0;
                }
            }
        },
        dianji5(val) {
            if (val.indexOf('客资费(上上级)') != -1) {
                this.checkboxsix = true;
            } else {
                this.checkboxsix = false;
                if (this.checkboxsix == false) {
                    this.form.cituikzmoney = 0;
                }
            }
            if (val.indexOf('提成(上上级)') != -1) {
                this.checkboxseven = true;
            } else {
                this.checkboxseven = false;
                if (this.checkboxseven == false) {
                    this.form.cituiticheng = 0;
                }
            }
        },
        // 推广
        tuiguang: function (row) {
            let userid = row.userid;
            this.$router.push({
                name: 'tuiguang',
                query: { userid: userid }
            })
        },
        // 银行卡
        yinghangka: function (row) {
            let userId = row.userid;
            this.$router.push({
                name: "yinhangka",
                query: { userId: userId }
            })
        },
        // 交易明细
        details: function (row) {
            let userId = row.userid;
            this.$router.push({
                name: "jiaoyimingxi",
                query: { userId: userId }
            })
        },
        // 冻结金额
        frozenjine(row) {
            this.open3 = true;
            this.title2 = "冻结金额"
            this.form1.userId = row.userid;
        },
        // 确定按钮操作
        sbumit() {
            this.$refs["form1"].validate(valid => {
                if (valid) {
                    this.lock2 = true;
                    djinsertjiedong(this.form1).then(response => {
                        if (response.data.code == 200) {
                            this.lock2 = false;
                            this.open3 = false;
                            this.form1 = {
                                userId: '',
                                cmmoney: '',
                                remark: '',
                            }
                            this.$modal.msgSuccess(response.data.msg);
                            this.getList();
                        } else {
                            this.lock2 = false;
                            this.$modal.msgError(response.data.msg);
                            this.open3 = false;
                            this.form1 = {
                                userId: '',
                                cmmoney: '',
                                remark: '',
                            }
                        }

                    })
                }
            })
        },
        cancel1() {
            this.open3 = false;
            this.form = {
                userId: '',
                cmmoney: '',
                remark: '',
            }
        },
        // 查看冻结金额
        frozen: function (row) {
            this.$router.push({
                name: "forzen",
                query: { userId: row.userid }
            })
        },
        // 验证搜索框日期
        beginDate() {
            const self = this;
            return {
                disabledDate(time) {
                    //           debugger;
                    if (self.endTime) {
                        //如果结束时间不为空，则小于结束时间
                        return new Date(self.endTime).getTime() < time.getTime();
                    } else {
                        return time.getTime() > Date.now()//开始时间不选时，结束时间最大值小于等于当天
                    }
                },
            };
        },
        processDate() {
            const self = this;
            return {
                disabledDate(time) {
                    if (self.startTime) {
                        //如果开始时间不为空，则结束时间大于开始时间
                        return new Date(self.startTime).getTime() > time.getTime();
                    } else {
                        return time.getTime() > Date.now()//开始时间不选时，结束时间最大值小于等于当天
                    }
                },
            };
        },
        // 导出
        async handleExport() {
            // this.$confirm('是否确认导出所有用户数据项?', "警告", {
            //     confirmButtonText: "确定",
            //     cancelButtonText: "取消",
            //     type: "warning"
            // }).then(function () {
            //     return excelyuangong();
            // }).then(response => {
            //     this.$download.name(response.msg);
            // }).catch(function () { });

            const queryParams = this.queryParams;
            let res = await excelyuangong(queryParams);
            if (res.code == 200) {
                this.isloading = false;
                this.$download.name(res.msg);
            }
        }
    }
};
</script>
<style scoped>
.el-form {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.el-table {
    line-height: 10px;
}

.el-image {
    width: 50px !important;
}

.avatar-uploader .el-upload {
    border: 1px solid #8c939d;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 78px;
    height: 78px;
    line-height: 78px;
    text-align: center;
    border: 1px solid #8c939d;
}

.avatar {
    width: 78px;
    height: 78px;
    display: block;
}

.jdt {
    position: absolute;
    top: 0px;
    left: 0px;
    background: rgba(0, 0, 0, 0.6);
}

#eye {
    position: absolute;
    left: 180px;
}
</style>
